package com.yyjj.hangqing.adapter;

import android.os.Bundle;
import android.view.View;

import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yyjj.hangqing.R;
import com.yyjj.hangqing.entity.CoinExchangeEntity;

import tech.com.commoncore.utils.OnNoDoubleClickListener;

/**
 * Time:2019/6/25
 * dec CoinApps
 */
public class CoinListAdapter extends BaseQuickAdapter<CoinExchangeEntity.DataBean,BaseViewHolder>{

    public CoinListAdapter(int layoutResId) {
        super(layoutResId);
    }

    @Override
    protected void convert(BaseViewHolder helper, final CoinExchangeEntity.DataBean item) {
        if (item.getCn_name().equals("－")){
            helper.setText(R.id.tv_title,item.getEn_name());
        }else {
            helper.setText(R.id.tv_title,item.getCn_name());
        }
        helper.setText(R.id.tv_price,item.getPrice())
                .setText(R.id.tv_percent,item.getFrom_to())
                .setOnClickListener(R.id.ll_item, new OnNoDoubleClickListener() {
                    @Override
                    public void onNoDoubleClick(View v) {
                        Bundle bundle = new Bundle();
                        bundle.putString("symbol",item.getSymbol());
                        ARouter.getInstance().build("/hq/kline/coin").with(bundle).navigation();
                    }
                });
    }
}
